/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sifisy.connections;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import sifisy.core.Model;
import sifisy.newgui.*;

/**
 *
 * @author Alessandro Vedovato
 */
public class Controller {
    Model model = new Model();
    String[] error = {
        "partErr0",
        "partErr1",
        "blockErr2",
        "blockErr3",
        "fileErr4",
        "fileErr5",
        "fragErr6",
        "i-nodeErr7",
        "i-nodeErr8",
        "i-nodeErr9",
        "i-nodeErr10",
        "speedErr11",
        "speedErr12",
        "trackErr13",
        "trackErr14",
        "nTrackErr15",
        "nTrackErr16",
        "bftErr17",
        "bftErr18",
        "mRecErr19",
        "mRecErr20",
        "eRecErr21",
        "eRecErr22",
        "consistenceErr23",
        "consistenceErr24",
        "nNumErr25",
        "nNumErr26",
        "nNumErr27",
        "nNumErr28",
        "nNumErr29",
        "nNumErr30",
        "nNumErr31",
        "nNumErr32",
        "nNumErr33",
        "nNumErr34",
        "nNumErr35",
        "nNumErr36",
        "consistenceErr37",
        "consistenceErr38"
    };

      /**
     * Returns the value of the exponent in base two of a size (KB, MB, GB or TB)
     * @param exponent
     * @return int
     */
    public int convertSize(String exponent) {
        if (exponent.equals("KB")) {
            return 10;
        }
        if (exponent.equals("MB")) {
            return 20;
        }
        if (exponent.equals("GB")) {
            return 30;
        }
        if (exponent.equals("TB")) {
            return 40;
        }
        return 0;
    }

    /**
     * calculate the dimension with byte.
     * ex: 2KB= 2* 2^10= 2048byte.
     * @param dimension
     * @param indexPow
     * @return int
     */
    public long dimensionPow(int dimension, int indexPow) {
        double value=(dimension * (Math.pow(2, indexPow)));
        return (long)value;
    }

//    /**
//     * Inner class that call Model to open an exist simulation
//     */
//    public class openSimulation implements ActionListener{
//
//        /**
//         * Method that call Model to open an exist simulation
//         * @param event
//         */
//        public void actionPerformed (ActionEvent event) {
//            String simPath ="";
//
//            model.openSimulation(simPath, null);
//        }
//    }
//
//        /**
//     * Inner class that call Model to save a simulation
//     */
//    public class saveSimulation implements ActionListener{
//
//        /**
//         * Method that call Model to save a simulation
//         * @param event
//         */
//        public void actionPerformed (ActionEvent event) {
//            int simId=0;
//            String simPath ="";
//            String fileName;
//
//            model.saveSimulation(simId, simPath, null);
//        }
//    }
//
//        /**
//     * Inner class that call Model to open an exist project
//     */
//    public class openProject implements ActionListener{
//
//         /**
//         * Method that call Model to open an exist project
//         * @param event
//         */
//        public void actionPerformed (ActionEvent event) {
//            String prjPath ="";
//            //DA INSERIRE NEL MODEL L'APERTURA DI PROGETTO
//            //model.openProject(prjPath, null);
//        }
//    }
//
//        /**
//     * Inner class that call Model to save a project
//     */
//    public class saveProject implements ActionListener{
//
//         /**
//         * Method that call Model to save a project
//         * @param event
//         */
//        public void actionPerformed (ActionEvent event) {
//            int prjId=0;
//            String simPath ="";
//            String fileName;
//            //DA FARE IL SAVE PROJECT SUL MODEL
//            //model.saveProject(prjId, prjPath, prjName);
//        }
//    }

  
}
